// var i;
// var AL_GAME_HUA_AddPrefab = require("./AL_GAME_HUA_AddPrefab");
// var AL_GAME_HUA_Instance = require("./AL_GAME_HUA_Instance");
// var AL_GAME_HUA_Common = require("./AL_GAME_HUA_Common");
// var AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");
// var AL_GAME_HUA_GameConst = require("./AL_GAME_HUA_GameConst");
// var AL_GAME_HUA_LevelConfig = require("./AL_GAME_HUA_LevelConfig");
// var AL_GAME_HUA_MissionConfig = require("./AL_GAME_HUA_MissionConfig");
// var AL_GAME_HUA_CurrencyData = require("./AL_GAME_HUA_CurrencyData");
// var AL_GAME_HUA_GameData = require("./AL_GAME_HUA_GameData");
// var AL_GAME_HUA_GameBase = require("./AL_GAME_HUA_GameBase");
// var AL_GAME_HUA_MGameUI = require("./AL_GAME_HUA_MGameUI");
// var AL_GAME_HUA_Stage = require("./AL_GAME_HUA_Stage");
// var AL_GAME_HUA_PlayerInfo = require("./AL_GAME_HUA_PlayerInfo");
// window.first_load = !1;
// var L = cc._decorator;
// var b = L.ccclass;
// var C = L.property;
// var H =
//     (L.menu,
//     (function (e) {
//         function t() {
//             var t = (null !== e && e.apply(this, arguments)) || this;
//             t.stage = null;
//             t.gameUI = null;
//             t.gameState = AL_GAME_HUA_Define.Define.GameState.PREPARE;
//             t.gameTime = 0;
//             t.totalTime = 0;
//             t.isTimePause = !1;
//             t.isStartTime = !1;
//             t.reviveTime = 0;
//             t._eventTimes = [15, 30, 300, 500];
//             t._gameTimeIndex = 0;
//             t._gameTimeInt = t._eventTimes[t._gameTimeIndex];
//             return t;
//         }
//         __extends(t, e);
//         t.prototype.onLoad = function () {
//             AL_GAME_HUA_Instance.Instance.Game = this;
//             AL_GAME_HUA_GameData.GameData.getInstance().shezhi_dangqian_guanqia();
//         };
//         t.prototype.start = function () {};
//         t.prototype.onPreload = function () {
//             return __awaiter(this, void 0, void 0, function () {
//                 return __generator(this, function (e) {
//                     switch (e.label) {
//                         case 0:
//                             return [4, this.stage.onPreload()];
//                         case 1:
//                             e.sent();
//                             return [4, this.gameUI.onPreload()];
//                         case 2:
//                             e.sent();
//                             return [2];
//                     }
//                 });
//             });
//         };
//         t.prototype.onPrepare = function () {
//             return __awaiter(this, void 0, void 0, function () {
//                 return __generator(this, function (e) {
//                     switch (e.label) {
//                         case 0:
//                             ailin_sdk_manager.addListenerBackKey({
//                                 node: this.node,
//                                 callBack: function () {}
//                             });
//                             this.gameState = AL_GAME_HUA_Define.Define.GameState.PREPARE;
//                             AL_GAME_HUA_Common.Common.youxi_kaishi();
//                             this.chushihua_shijian();
//                             return [4, Promise.all([this.gameUI.onPrepare(), this.stage.onPrepare()])];
//                         case 1:
//                             e.sent();
//                             this.chuli_youxi_kaishi();
//                             return [2];
//                     }
//                 });
//             });
//         };
//         t.prototype.chuli_youxi_kaishi = function () {
//             return __awaiter(this, void 0, void 0, function () {
//                 return __generator(this, function (e) {
//                     switch (e.label) {
//                         case 0:
//                             "tt" == ailin_sdk_manager.getSysPlatformName()
//                                 ? (ailin_sdk_manager.kaishiLuping(), ailin_sdk_manager.yincangBannerGuanggao())
//                                 : ailin_sdk_manager.yincangBannerGuanggao();
//                             return [4, this.stage.chuli_youxi_kaishi()];
//                         case 1:
//                             e.sent();
//                             return [4, this.gameUI.chuli_youxi_kaishi()];
//                         case 2:
//                             e.sent();
//                             this.gameState = AL_GAME_HUA_Define.Define.GameState.PLAYING;
//                             return [2];
//                     }
//                 });
//             });
//         };
//         t.prototype.chuli_youxi_shengli = function () {
//             return __awaiter(this, void 0, void 0, function () {
//                 var e;
//                 var t;
//                 var n;
//                 var o;
//                 return __generator(this, function (i) {
//                     switch (i.label) {
//                         case 0:
//                             ailin_sdk_manager.tingzhiLuping();
//                             AL_GAME_HUA_Common.Common.youxi_shengli();
//                             AL_GAME_HUA_Instance.Instance.Game.gameState = AL_GAME_HUA_Define.Define.GameState.WIN;
//                             return AL_GAME_HUA_Instance.Instance.LevelType != AL_GAME_HUA_Define.Define.LevelType.NORMAL
//                                 ? [3, 2]
//                                 : (AL_GAME_HUA_GameData.GameData.getInstance().jiesuo_xin_guanqia(
//                                       AL_GAME_HUA_GameData.GameData.getInstance().huoqu_yijiesuo_guanqia() + 1
//                                   ),
//                                   this.stage.chuli_youxi_shengli(),
//                                   [4, this.gameUI.chuli_youxi_shengli()]);
//                         case 1:
//                             i.sent();
//                             AL_GAME_HUA_PlayerInfo.PlayerInfo.getInstance().zengjia_dengji();
//                             AL_GAME_HUA_Common.Common.bofang_yinxiao("youxi_shengli", this);
//                             e = this.gameUI.starNum;
//                             t = this.stage.levelData.Type;
//                             AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
//                                 AL_GAME_HUA_MissionConfig.MissionType.CRASH,
//                                 t
//                             );
//                             n = Math.ceil(t * AL_GAME_HUA_GameConst.GameConst.getInstance().pass_reward);
//                             o = Math.clamp(n, 20, 500);
//                             AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_shengli_mianban({
//                                 star: e,
//                                 gold: o
//                             });
//                             return [3, 10];
//                         case 2:
//                             return AL_GAME_HUA_Instance.Instance.LevelType !=
//                                 AL_GAME_HUA_Define.Define.LevelType.CHALLENGE
//                                 ? [3, 8]
//                                 : 1 != AL_GAME_HUA_Instance.Instance.ChallengeLevel
//                                 ? [3, 5]
//                                 : ((AL_GAME_HUA_Instance.Instance.ChallengeLevel = 2),
//                                   AL_GAME_HUA_Instance.Instance.LevelType != AL_GAME_HUA_Define.Define.LevelType.CHALLENGE
//                                       ? [3, 4]
//                                       : [4, this.gameUI.xianshi_wancheng_donghua()]);
//                         case 3:
//                             i.sent();
//                             i.label = 4;
//                         case 4:
//                             AL_GAME_HUA_Instance.Instance.qianwang_youxi();
//                             return [3, 7];
//                         case 5:
//                             return 2 != AL_GAME_HUA_Instance.Instance.ChallengeLevel
//                                 ? [3, 7]
//                                 : (this.stage.chuli_youxi_shengli(), [4, this.gameUI.chuli_youxi_shengli()]);
//                         case 6:
//                             i.sent();
//                             e = this.gameUI.starNum;
//                             AL_GAME_HUA_AddPrefab.AddPrefab.create_challenge_result({
//                                 label_star_count: e,
//                                 complete: !0
//                             });
//                             AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
//                                 AL_GAME_HUA_MissionConfig.MissionType.CRASH,
//                                 this.gameUI.popNum
//                             );
//                             i.label = 7;
//                         case 7:
//                             return [3, 10];
//                         case 8:
//                             return AL_GAME_HUA_Instance.Instance.LevelType != AL_GAME_HUA_Define.Define.LevelType.SPECIAL
//                                 ? [3, 10]
//                                 : (AL_GAME_HUA_GameData.GameData.getInstance().jiesuo_xin_teshu_guanqia(
//                                       AL_GAME_HUA_GameData.GameData.getInstance().huoqu_yijiesuo_teshu_guanqia() + 1
//                                   ),
//                                   this.stage.chuli_youxi_shengli(),
//                                   [4, this.gameUI.chuli_youxi_shengli()]);
//                         case 9:
//                             i.sent();
//                             AL_GAME_HUA_Common.Common.bofang_yinxiao("youxi_shengli", this);
//                             AL_GAME_HUA_PlayerInfo.PlayerInfo.getInstance().zengjia_dengji();
//                             e = this.gameUI.starNum;
//                             t = this.stage.levelData.Type;
//                             AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
//                                 AL_GAME_HUA_MissionConfig.MissionType.CRASH,
//                                 t
//                             );
//                             n = Math.ceil(t * AL_GAME_HUA_GameConst.GameConst.getInstance().pass_reward);
//                             o = Math.clamp(n, 20, 500);
//                             AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_shengli_mianban({
//                                 star: e,
//                                 gold: o
//                             });
//                             i.label = 10;
//                         case 10:
//                             return [2];
//                     }
//                 });
//             });
//         };
//         t.prototype.chuli_youxi_shibai = function () {
//             return __awaiter(this, void 0, void 0, function () {
//                 return __generator(this, function () {
//                     ailin_sdk_manager.tingzhiLuping();
//                     AL_GAME_HUA_Instance.Instance.Game.gameState = AL_GAME_HUA_Define.Define.GameState.FAIL;
//                     this.stage.chuli_youxi_shibai();
//                     this.gameUI.chuli_youxi_shibai();
//                     AL_GAME_HUA_Common.Common.bofang_yinxiao("game_lose", this);
//                     AL_GAME_HUA_Common.Common.youxi_shibai();
//                     AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.NORMAL
//                         ? AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_shibai_mianban()
//                         : AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.CHALLENGE
//                         ? AL_GAME_HUA_AddPrefab.AddPrefab.create_challenge_result({
//                               label_star_count: 0,
//                               complete: !1
//                           })
//                         : AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.SPECIAL &&
//                           AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_shibai_mianban();
//                     return [2];
//                 });
//             });
//         };
//         t.prototype.chuli_youxi_zhanting = function () {
//             ailin_sdk_manager.zantingLuping();
//             this.gameState = AL_GAME_HUA_Define.Define.GameState.PAUSE;
//             this.gameUI.chuli_youxi_zhanting();
//             this.stage.chuli_youxi_zhanting();
//             AL_APP_SDK_MANAGER.emit(AL_GAME_HUA_Define.GameEvent.ON_GAME_PAUSE);
//         };
//         t.prototype.chuli_youxi_jixu = function () {
//             ailin_sdk_manager.resumeLuPing();
//             this.gameState = AL_GAME_HUA_Define.Define.GameState.PLAYING;
//             this.gameUI.chuli_youxi_jixu();
//             this.stage.chuli_youxi_jixu();
//             AL_APP_SDK_MANAGER.emit(AL_GAME_HUA_Define.GameEvent.ON_GAME_RESUME);
//         };
//         t.prototype.chuli_youxi_tuichu = function () {
//             AL_GAME_HUA_Common.Common.youxi_shibai();
//         };
//         t.prototype.chuli_youxi_chongxinkaishi = function () {
//             this.chuli_youxi_tuichu();
//             AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.NORMAL
//                 ? AL_GAME_HUA_Instance.Instance.qianwang_youxi()
//                 : AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.CHALLENGE
//                 ? ((AL_GAME_HUA_Instance.Instance.ChallengeLevel = 1), AL_GAME_HUA_Instance.Instance.qianwang_youxi())
//                 : AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.SPECIAL &&
//                   AL_GAME_HUA_Instance.Instance.qianwang_youxi();
//         };
//         t.prototype.chuli_fanhui_zhujiemain = function (e) {
//             if (void 0 === e) {
//                 e = !1;
//             }
//             if (e) {
//                 this.chuli_youxi_tuichu();
//             }
//             AL_GAME_HUA_Instance.Instance.jinru_zhujiemian();
//         };
//         t.prototype.chuli_youxi_chaoshi = function () {
//             var e = this;
//             this.gameState = AL_GAME_HUA_Define.Define.GameState.PAUSE;
//             AL_GAME_HUA_Common.Common.bofang_yinxiao("timeout", this);
//             var t = Math.min(60 + 10 * this.reviveTime, 120);
//             if (AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.SPECIAL) {
//                 var n = AL_GAME_HUA_GameConst.GameConst.getInstance().specail_revive;
//                 if (-1 != n && this.reviveTime >= n) {
//                     return void this.chuli_youxi_shibai();
//                 }
//             }
//             AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_shijian_jiesu_mianban({
//                 time: t,
//                 onGiveUp: function () {
//                     AL_GAME_HUA_Common.Common.xianshiChapingGuanggaoWanchengshi(function () {
//                         var e = AL_GAME_HUA_GameConst.GameConst.getInstance().reward_coin;
//                         AL_GAME_HUA_CurrencyData.CurrencyData.getInstance().tianjia_huobi({
//                             type: AL_GAME_HUA_CurrencyData.CurrencyType.COIN,
//                             num: e
//                         });
//                         AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_tishi_jiedian_mianban({
//                             str: "获得x金币",
//                             params: [e.toString()]
//                         });
//                     });
//                     AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.NORMAL
//                         ? e.chuli_fanhui_zhujiemain(!0)
//                         : AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.CHALLENGE
//                         ? (e.chuli_youxi_tuichu(),
//                           AL_GAME_HUA_AddPrefab.AddPrefab.create_challenge_result({
//                               label_star_count: 0,
//                               complete: !1
//                           }))
//                         : AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.SPECIAL &&
//                           e.chuli_youxi_shibai();
//                 },
//                 onVideo: function () {
//                     e.isStartTime = !1;
//                     e.chuli_zengjia_shijian(t);
//                     e.reviveTime++;
//                 }
//             });
//         };
//         t.prototype.chuli_zengjia_shijian = function (e) {
//             AL_GAME_HUA_Common.Common.bofang_yinxiao("shop_purchase", this);
//             this.totalTime += e;
//             var t = this.totalTime - this.gameTime;
//             this.gameUI.shuaxin_shijian(t);
//             this.gameState = AL_GAME_HUA_Define.Define.GameState.PLAYING;
//         };
//         t.prototype.chushihua_shijian = function () {
//             var e = AL_GAME_HUA_LevelConfig.LevelConfig.getInstance();
//             var t = AL_GAME_HUA_GameData.GameData.getInstance();
//             this.gameTime = 0;
//             AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.NORMAL
//                 ? (this.totalTime = e.huoqu_peizhi_by_level(t.huoqu_yijiesuo_guanqia()).Time)
//                 : AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.CHALLENGE
//                 ? (this.totalTime = e.huoqu_tiaozhan_guanqia_peizhi_by_date(AL_GAME_HUA_Instance.Instance.ChallengeLevel).Time)
//                 : AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.SPECIAL &&
//                   (this.totalTime = e.huoqu_teshu_guanqia_peizhi_by_level(t.huoqu_yijiesuo_teshu_guanqia()).Time);
//             this.gameUI.shuaxin_shijian(this.totalTime);
//         };
//         t.prototype.huoqu_shengyu_shijian = function () {
//             return this.totalTime - this.gameTime;
//         };
//         t.prototype.update = function (e) {
//             if (this.gameState == AL_GAME_HUA_Define.Define.GameState.PLAYING) {
//                 if (!this.isTimePause && this.isStartTime) {
//                     this.gameTime += e;
//                     var t = this.totalTime - this.gameTime;
//                     this.gameUI.shuaxin_shijian(t);
//                     if (t <= 0) {
//                         this.gameTime = this.totalTime;
//                         this.chuli_youxi_chaoshi();
//                     }
//                 }
//                 this.stage.chuli_zhen_gengxin(e);
//             }
//         };
//         t.prototype.onDestroy = function () {
//             AL_APP_SDK_MANAGER.off(this);
//             AL_GAME_HUA_Instance.Instance.Game = null;
//         };
//         __decorate([C(AL_GAME_HUA_Stage.default)], t.prototype, "stage", void 0);
//         __decorate([C(AL_GAME_HUA_MGameUI.default)], t.prototype, "gameUI", void 0);
//         return __decorate([b], t);
//     })(AL_GAME_HUA_GameBase.default));
// exports.default = H;

// 引入各类模块
const AL_GAME_HUA_AddPrefab = require("./AL_GAME_HUA_AddPrefab");
const AL_GAME_HUA_Instance = require("./AL_GAME_HUA_Instance");
const AL_GAME_HUA_Common = require("./AL_GAME_HUA_Common");
const AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");
const AL_GAME_HUA_GameConst = require("./AL_GAME_HUA_GameConst");
const AL_GAME_HUA_LevelConfig = require("./AL_GAME_HUA_LevelConfig");
const AL_GAME_HUA_MissionConfig = require("./AL_GAME_HUA_MissionConfig");
const AL_GAME_HUA_CurrencyData = require("./AL_GAME_HUA_CurrencyData");
const AL_GAME_HUA_GameData = require("./AL_GAME_HUA_GameData");
const AL_GAME_HUA_GameBase = require("./AL_GAME_HUA_GameBase");
const AL_GAME_HUA_MGameUI = require("./AL_GAME_HUA_MGameUI");
const AL_GAME_HUA_Stage = require("./AL_GAME_HUA_Stage");
const AL_GAME_HUA_PlayerInfo = require("./AL_GAME_HUA_PlayerInfo");

window.first_load = false;

const { ccclass, property, menu } = cc._decorator;

@ccclass
class GameController extends AL_GAME_HUA_GameBase.default {
    @property(AL_GAME_HUA_Stage.default)
    stage = null;

    @property(AL_GAME_HUA_MGameUI.default)
    gameUI = null;

    gameState = AL_GAME_HUA_Define.Define.GameState.PREPARE;
    gameTime = 0;
    totalTime = 0;
    isTimePause = false;
    isStartTime = false;
    reviveTime = 0;
    _eventTimes = [15, 30, 300, 500];
    _gameTimeIndex = 0;
    _gameTimeInt = this._eventTimes[this._gameTimeIndex];

    onLoad() {
        AL_GAME_HUA_Instance.Instance.Game = this;
        AL_GAME_HUA_GameData.GameData.getInstance().shezhi_dangqian_guanqia();
    }

    start() {}

    async onPreload() {
        await this.stage.onPreload();
        await this.gameUI.onPreload();
    }

    async onPrepare() {
        ailin_sdk_manager.addListenerBackKey({
            node: this.node,
            callBack: function () {}
        });
        this.gameState = AL_GAME_HUA_Define.Define.GameState.PREPARE;
        AL_GAME_HUA_Common.Common.youxi_kaishi();
        this.chushihua_shijian();
        await Promise.all([this.gameUI.onPrepare(), this.stage.onPrepare()]);
        this.chuli_youxi_kaishi();
    }

    async chuli_youxi_kaishi() {
        if (ailin_sdk_manager.getSysPlatformName() === "tt") {
            ailin_sdk_manager.kaishiLuping();
            ailin_sdk_manager.yincangBannerGuanggao();
        } else {
            ailin_sdk_manager.yincangBannerGuanggao();
        }
        await this.stage.chuli_youxi_kaishi();
        await this.gameUI.chuli_youxi_kaishi();
        this.gameState = AL_GAME_HUA_Define.Define.GameState.PLAYING;
    }

    async chuli_youxi_shengli() {
        ailin_sdk_manager.tingzhiLuping();
        AL_GAME_HUA_Common.Common.youxi_shengli();
        AL_GAME_HUA_Instance.Instance.Game.gameState = AL_GAME_HUA_Define.Define.GameState.WIN;

        if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.NORMAL) {
            AL_GAME_HUA_GameData.GameData.getInstance().jiesuo_xin_guanqia(
                AL_GAME_HUA_GameData.GameData.getInstance().huoqu_yijiesuo_guanqia() + 1
            );
            await this.stage.chuli_youxi_shengli();
            await this.gameUI.chuli_youxi_shengli();
            AL_GAME_HUA_PlayerInfo.PlayerInfo.getInstance().zengjia_dengji();
            AL_GAME_HUA_Common.Common.bofang_yinxiao("game_win", this);

            const e = this.gameUI.starNum;
            const t = this.stage.levelData.Type;
            AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
                AL_GAME_HUA_MissionConfig.MissionType.CRASH,
                t
            );
            const n = Math.ceil(t * AL_GAME_HUA_GameConst.GameConst.getInstance().pass_reward);
            const o = Math.clamp(n, 20, 500);
            AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_shengli_mianban({
                star: e,
                gold: o
            });
        }
        else if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.CHALLENGE) {
            if (AL_GAME_HUA_Instance.Instance.ChallengeLevel === 1) {
                AL_GAME_HUA_Instance.Instance.ChallengeLevel = 2;
                await this.gameUI.xianshi_wancheng_donghua();
                AL_GAME_HUA_Instance.Instance.qianwang_youxi();
            } else if (AL_GAME_HUA_Instance.Instance.ChallengeLevel === 2) {
                await this.stage.chuli_youxi_shengli();
                await this.gameUI.chuli_youxi_shengli();
                const e = this.gameUI.starNum;
                AL_GAME_HUA_AddPrefab.AddPrefab.create_challenge_result({
                    label_star_count: e,
                    complete: true
                });
                AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
                    AL_GAME_HUA_MissionConfig.MissionType.CRASH,
                    this.gameUI.popNum
                );
            }
        }
        else if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.SPECIAL) {
            AL_GAME_HUA_GameData.GameData.getInstance().jiesuo_xin_teshu_guanqia(
                AL_GAME_HUA_GameData.GameData.getInstance().huoqu_yijiesuo_teshu_guanqia() + 1
            );
            await this.stage.chuli_youxi_shengli();
            await this.gameUI.chuli_youxi_shengli();
            AL_GAME_HUA_PlayerInfo.PlayerInfo.getInstance().zengjia_dengji();

            const e = this.gameUI.starNum;
            const t = this.stage.levelData.Type;
            AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
                AL_GAME_HUA_MissionConfig.MissionType.CRASH,
                t
            );
            const n = Math.ceil(t * AL_GAME_HUA_GameConst.GameConst.getInstance().pass_reward);
            const o = Math.clamp(n, 20, 500);
            AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_shengli_mianban({
                star: e,
                gold: o
            });
        }
    }

    async chuli_youxi_shibai() {
        ailin_sdk_manager.tingzhiLuping();
        AL_GAME_HUA_Instance.Instance.Game.gameState = AL_GAME_HUA_Define.Define.GameState.FAIL;
        this.stage.chuli_youxi_shibai();
        this.gameUI.chuli_youxi_shibai();
        AL_GAME_HUA_Common.Common.bofang_yinxiao("game_lose", this);
        console.log("on_game_fail首页22")
        AL_GAME_HUA_Common.Common.youxi_shibai();
        console.log("on_game_fail首页33")
        if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.NORMAL) {
            AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_shibai_mianban();
        } else if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.CHALLENGE) {
            AL_GAME_HUA_AddPrefab.AddPrefab.create_challenge_result({
                label_star_count: 0,
                complete: false
            });
        } else if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.SPECIAL) {
            AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_shibai_mianban();
        }
    }

    chuli_youxi_zhanting() {
        ailin_sdk_manager.zantingLuping();
        this.gameState = AL_GAME_HUA_Define.Define.GameState.PAUSE;
        this.gameUI.chuli_youxi_zhanting();
        this.stage.chuli_youxi_zhanting();
        AL_APP_SDK_MANAGER.emit(AL_GAME_HUA_Define.GameEvent.ON_GAME_PAUSE);
    }

    chuli_youxi_jixu() {
        ailin_sdk_manager.resumeLuPing();
        this.gameState = AL_GAME_HUA_Define.Define.GameState.PLAYING;
        this.gameUI.chuli_youxi_jixu();
        this.stage.chuli_youxi_jixu();
        AL_APP_SDK_MANAGER.emit(AL_GAME_HUA_Define.GameEvent.ON_GAME_RESUME);
    }

    chuli_youxi_tuichu() {
        AL_GAME_HUA_Common.Common.youxi_shibai();
    }

    chuli_youxi_chongxinkaishi() {
        this.chuli_youxi_tuichu();
        if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.NORMAL) {
            AL_GAME_HUA_Instance.Instance.qianwang_youxi();
        } else if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.CHALLENGE) {
            AL_GAME_HUA_Instance.Instance.ChallengeLevel = 1;
            AL_GAME_HUA_Instance.Instance.qianwang_youxi();
        } else if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.SPECIAL) {
            AL_GAME_HUA_Instance.Instance.qianwang_youxi();
        }
    }

    chuli_fanhui_zhujiemain(isExit = false) {
        if (isExit) {
            this.chuli_youxi_tuichu();
        }
        AL_GAME_HUA_Instance.Instance.jinru_zhujiemian();
    }

    chuli_youxi_chaoshi() {
        this.gameState = AL_GAME_HUA_Define.Define.GameState.PAUSE;
        AL_GAME_HUA_Common.Common.bofang_yinxiao("timeout", this);

        const extraTime = Math.min(60 + 10 * this.reviveTime, 120);

        if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.SPECIAL) {
            const n = AL_GAME_HUA_GameConst.GameConst.getInstance().specail_revive;
            if (n !== -1 && this.reviveTime >= n) {
                this.chuli_youxi_shibai();
                return;
            }
        }

        AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_shijian_jiesu_mianban({
            time: extraTime,
            onGiveUp: () => {
                AL_GAME_HUA_Common.Common.xianshiChapingGuanggaoWanchengshi(() => {
                    const rewardCoin = AL_GAME_HUA_GameConst.GameConst.getInstance().reward_coin;
                    AL_GAME_HUA_CurrencyData.CurrencyData.getInstance().tianjia_huobi({
                        type: AL_GAME_HUA_CurrencyData.CurrencyType.COIN,
                        num: rewardCoin
                    });
                    AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_tishi_jiedian_mianban({
                        str: "获得x金币",
                        params: [rewardCoin.toString()]
                    });
                });

                if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.NORMAL) {
                    this.chuli_fanhui_zhujiemain(true);
                } else if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.CHALLENGE) {
                    this.chuli_youxi_tuichu();
                    AL_GAME_HUA_AddPrefab.AddPrefab.create_challenge_result({
                        label_star_count: 0,
                        complete: false
                    });
                } else if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.SPECIAL) {
                    this.chuli_youxi_shibai();
                }
            },
            onVideo: () => {
                this.isStartTime = false;
                this.chuli_zengjia_shijian(extraTime);
                this.reviveTime++;
            }
        });
    }

    chuli_zengjia_shijian(extraTime) {
        AL_GAME_HUA_Common.Common.bofang_yinxiao("shop_purchase", this);
        this.totalTime += extraTime;
        const remainingTime = this.totalTime - this.gameTime;
        this.gameUI.shuaxin_shijian(remainingTime);
        this.gameState = AL_GAME_HUA_Define.Define.GameState.PLAYING;
    }

    chushihua_shijian() {
        const e = AL_GAME_HUA_LevelConfig.LevelConfig.getInstance();
        const t = AL_GAME_HUA_GameData.GameData.getInstance();

        this.gameTime = 0;

        if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.NORMAL) {
            this.totalTime = e.huoqu_peizhi_by_level(t.huoqu_yijiesuo_guanqia()).Time;
        } else if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.CHALLENGE) {
            this.totalTime = e.huoqu_tiaozhan_guanqia_peizhi_by_date(AL_GAME_HUA_Instance.Instance.ChallengeLevel).Time;
        } else if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.SPECIAL) {
            this.totalTime = e.huoqu_teshu_guanqia_peizhi_by_level(t.huoqu_yijiesuo_teshu_guanqia()).Time;
        }

        this.gameUI.shuaxin_shijian(this.totalTime);
    }

    huoqu_shengyu_shijian() {
        return this.totalTime - this.gameTime;
    }

    update(e) {
        if (this.gameState === AL_GAME_HUA_Define.Define.GameState.PLAYING) {
            if (!this.isTimePause && this.isStartTime) {
                this.gameTime += e;
                const remainingTime = this.totalTime - this.gameTime;
                this.gameUI.shuaxin_shijian(remainingTime);

                if (remainingTime <= 0) {
                    this.gameTime = this.totalTime;
                    this.chuli_youxi_chaoshi();
                }
            }
            this.stage.chuli_zhen_gengxin(e);
        }
    }

    onDestroy() {
        AL_APP_SDK_MANAGER.off(this);
        AL_GAME_HUA_Instance.Instance.Game = null;
    }
}

exports.default = GameController;